public class test {
    public static void main(String[] args) {
        String s = "Hello world";
        char a= s.charAt(0);
//        if(a == ' '){
//            System.out.println();
//        }
        System.out.println(s.length());
    }
    public int lengthOfLastWord(String s) {
        int num = 0;
        int nex = 0;
        for(int i = 0;i < s.length();i++){
            char cur = s.charAt(i);
            if(cur == ' '){
                if(num != 0){
                    nex = num;
                }
                num = 0;
            }else{
                num++;
            }
        }
        if(num == 0){
            return nex;
        }
        return num;
    }
}
